class LoginController < ApplicationController
  layout "admin"

  def add_user
    @user = User.new(params[:user])
    if request.post? and @user.save
      flash.now[:notice] = "User #{@user.email} created."
      @user = User.new
    end
  end

  def login
  end

  def logout
  end

  def index
  end

  def delete_user
    if request.delete?
      user = User.find(params[:id])
      if user and user.safe_destroy
        flash[:notice] = "User #{user.email} destroyed"
      else
        flash[:error] = "Could not destroy: User not found or last superadmin"
      end
    end
    redirect_to :action => 'list_users'
  end

  def list_users
    @users = User.find(:all, :order => 'name')
  end
end
